package com.csun.cmny.provider.controller.rpc;

import com.csun.cmny.provider.model.vo.DeviceAlertReqVo;
import com.csun.cmny.provider.model.vo.DeviceReqVo;
import com.csun.cmny.provider.service.DmcDeviceAlertFeignApi;
import com.csun.cmny.provider.service.DmcDeviceAlertService;
import com.csun.cmny.provider.service.impl.JPushService;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-03-28 13:38
 * @Description: the class device alert feign api client
 */
@RestController
public class DmcDeviceAlertFeignApiClient implements DmcDeviceAlertFeignApi {

    @Resource
    private DmcDeviceAlertService dmcDeviceAlertService;

    @Resource
    private JPushService jPushService;

    @Override
    public Wrapper<List<DeviceAlertReqVo>> queryDeviceAlertByDeviceList(@RequestBody List<DeviceReqVo> deviceReqVoList) {

        List<DeviceAlertReqVo> deviceAlertReqVoList = dmcDeviceAlertService.queryDeviceAlertByDeviceList(deviceReqVoList);

        return WrapMapper.ok(deviceAlertReqVoList);
    }

    @Override
    public Wrapper<Integer> sendThresholdSaveMsg(@RequestBody List<String> tagList) {

        jPushService.sendThresholdSaveMsg(tagList);

        return WrapMapper.ok(1);
    }

    @Override
    public Wrapper<Integer> sendBuildingFloorUpdateMsg(@RequestBody List<String> tagList) {

        jPushService.sendBuildingFloorUpdateMsg(tagList);

        return WrapMapper.ok(1);
    }

    @Override
    public Wrapper<List<DeviceAlertReqVo>> queryDeviceAlertByOldIdAndDate(@RequestBody DeviceAlertReqVo deviceAlertReqVo) {

        List<DeviceAlertReqVo> deviceAlertReqVos = dmcDeviceAlertService.queryDeviceAlertByOldIdAndDate(deviceAlertReqVo);

        return WrapMapper.ok(deviceAlertReqVos);
    }
}
